import { lazy } from 'react'
import { RouteObject } from 'react-router'

const Error404 = lazy(() => import('@/views/error/404'))
const Layout = lazy(() => import('@/layout/index'))
const DataAsset = lazy(() => import('@/views/dataAsset/index'))

const Login = lazy(() => import('@/views/login/index'))

const Counter = lazy(() => import('@/views/counter/index'))

const About = lazy(() => import('@/views/dynamic/About'))
const Test = lazy(() => import('@/views/dynamic/Test'))

export const dynamicRoutes = (): Promise<RouteObject[]> => new Promise((resolve) => {
  const routes: RouteObject[] = [
    { path: '/dynamic/about', element: <About /> },
    { path: '/dynamic/test', element: <Test /> }
  ]

  setTimeout(() => resolve(routes), 3000)
})

export default {
  Error404,
  Layout,
  DataAsset,
  Login,
  Counter,
}